<?php $duans = $this->requestAction('tinraos/addtinrao'); ?>
<script type="text/javascript">
	$(document).ready(function(){
		$("#submit-form").click(function(){
			//alert("a");
			//$('#PostFormClassified').post('http://www.google.com/recaptcha/api/verify', $("recaptcha_challenge_field").val(),function(data){
			//	alert("susscess");
			//});
		});
		 Recaptcha.create("6Lc15ccSAAAAAGr7AyJ0GBNF8h3TvdzrnJdyMfwJ", 'captchadiv', {
			theme: "red",
			callback: Recaptcha.focus_response_field
		});
	});
	$(function() {
		function format(mail) {
			return mail.label;
		}		
		$("#search_duan").autocomplete('<?php echo $this->webroot;?>/duans/autocomplete', {
			multiple: false,
			dataType: "json",
			parse: function(data) {
				return $.map(data, function(row) {
					return {
						data: row,
						value: row.value,
						result: row.label
					}
				});
			},
			formatItem: function(item) {
				return format(item);
			}
		}).result(function(e, item) {
			$(".idduanforaddtinrao").val(item.id);
		});
	});
</script>
<h1 class="underline">Đăng tin rao</h1>
<div class="">			
	<form action="<?php echo $this->webroot;?>/tinraos/add" method="post" class="edit-form" id="PostFormClassified">
		<table class="contact-table">				
			<tr><td>Tìm dự án:</td></tr>
			<tr>				
				<td>
					<input type="text" id="search_duan" />
					<input type="hidden" name="idduan" class="idduanforaddtinrao">
				</td>
			</tr>
			<tr><td>Tiêu đề:</td></tr>
			<tr>				
				<td><input type="text" name="tieude" class="title-input"></td>
			</tr>
			<tr><td>Nội dung:</td></tr>
			<tr>				
				<td><textarea id="textarea" name="noidung" class="autogrow"></textarea></td>
			</tr>
			<tr><td>Tên liên hệ:</td></tr>
			<tr>				
				<td><input type="text" name="tenlienhe"></td>
			</tr>
			<tr><td>Số điện thoại liên hệ:</td></tr>
			<tr>				
				<td><input type="text" name="sdtlienhe"></td>
			</tr>
			<tr><td>Email liên hệ:</td></tr>
			<tr>				
				<td><input type="text" name="email"><td>
			</tr>
			<tr><td>Mã xác nhận:<span class="capcha">&nbsp;<?php echo $html->image($html->url(array('controller'=>'tinraos', 'action'=>'captcha'), true),array('style'=>'','vspace'=>2)); ?></span></td></tr>
			<tr>				
				<td><input type="text" name="capcha"><td>
			</tr>
			<tr>
				<td>
					<div id="captchadiv"></div>
				</td>
			</tr>
		</table>
		<input type="submit" id="submit-form" value="Đăng tin"/>		
	</form>
</div>